define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function(){
		this.callParent();
	};

	Model.prototype.modelParamsReceive = function(event){
	
	      
	       if(event.params.images){
	    	   var imagePathList = event.params.images.substr(1).split("|");
	    	   this.makeCarousel(imagePathList);
	          
	       }else{
	       
	    	   this.comp("carousel2").add("<img class='item active' src='"+require.toUrl("$UI/communityOto/home/img/nophoto.jpg")+"' style='width:100%;height:280px;'>");
	    	   this.comp("carousel2").to(0);
	       }
	       
	       $("h4").text(event.params.title);
	       $("#"+this.getIDByXID("description")).html(event.params.description);
	       console.log(this.params.introduce);
	       $("#"+this.getIDByXID("introduce")).html(this.params.introduce);
	       $("#" + this.getIDByXID("price")).text("￥"+this.params.price);
	       $("#"+this.getIDByXID("panel2")).show();

	};
	
	
	Model.prototype.makeCarousel= function(imagePathList){
	    var me = this;
		var carouselContent = "";
		var indicatorContent = "";
		var carouselId = this.getIDByXID("carouse2");
		var carouselContentId = this.getIDByXID("contents2");
		var carouselIndicatorId = this.getIDByXID("ol2");
		
		for(var i = 0;i < imagePathList.length;i++){
		    var divClass = i===0?"item active":"item";
		    
			var imgHtml = "<div class='x-contents-content " + divClass + "' xid='page"+i+"' style='height:100%;'><div><img style='width:100%;height:280px;' src='http://www.xjzlhy.com:81" + imagePathList[i]+"'></div></div>";
			//carouselContent += imgHtml;
			$("#"+carouselContentId).append(imgHtml);
			
			 //this.comp("carousel2").add(carouselContent);
		}
		
		for(var j = 0;j < imagePathList.length;j++){
		    
			var liClass = j===0?' class="active"':'';
//			 
			var liHtml = "<li data-target='#"+carouselId+"'"+" data-slide-to='"+j+"'"+ liClass+"></li>"; 
			$("#"+carouselIndicatorId).append(liHtml);
           
		}
		
		
		$(".carousel-indicators li").click(function(){
		   
			me.comp("carousel2").to(parseInt($(this).attr("data-slide-to")));
				
		});

        
		
		//$("#"+carouselContentId).html(carouselContent);
		//$("#"+carouselIndicatorId).html(indicatorContent);
		
	};

	
	return Model;
});